package com.ixion.mongo;

public class Pager {
	private long page = 1;
	private int pageSize = 15;

	public Pager() {
	}

	/**
	 * @param page
	 */
	public Pager(long page) {
		super();
		this.page = page;
	}

	/**
	 * @param pageSize
	 */
	public Pager(int pageSize) {
		super();
		this.pageSize = pageSize;
	}

	/**
	 * @param page
	 * @param pageSize
	 */
	public Pager(int page, int pageSize) {
		super();
		this.page = page;
		this.pageSize = pageSize;
	}

	/**
	 * @return the page
	 */
	public long getPage() {
		return page;
	}

	/**
	 * @param page
	 *            the page to set
	 */
	public void setPage(long page) {
		this.page = page;
	}

	/**
	 * @return the pageSize
	 */
	public int getPageSize() {
		return pageSize;
	}

	/**
	 * @param pageSize
	 *            the pageSize to set
	 */
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Pager [page=" + page + ", pageSize=" + pageSize + "]";
	}

	public int start() {
		return (int) (page <= 1 ? 0 : (page - 1) * pageSize);
	}

	public long end() {
		return start() + pageSize;
	}

}
